package org.example.apifallback.util;

import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiClass;

import java.util.Objects;
import java.util.Optional;

/**
 * @author zengxiaoyu
 * @date 2025/7/31 18:32
 */
public class AnnotationUtils {


    /**
     * 查找注解
     *
     * @param psiClass       类对象
     * @param annotationName 注解名称
     */
    public static Optional<PsiAnnotation> findAnnotation(PsiClass psiClass, String annotationName) {
        for (PsiAnnotation annotation : psiClass.getAnnotations()) {
            if (Objects.requireNonNull(annotation.getQualifiedName()).endsWith(annotationName)) {
                return Optional.of(annotation);
            }
        }
        return Optional.empty();
    }
}
